package com.ict.web.controller.yzq;

import java.util.List;

import com.ict.web.domain.OrganizationManagement;
import com.ict.web.dto.InsertOrganizationManagementDto;
import com.ict.web.dto.QueryOrganizationManagementDto;
import com.ict.web.dto.UpdateOrganizationManagementDto;
import com.ict.web.service.IOrganizationManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.enums.BusinessType;
import com.ict.common.core.page.TableDataInfo;

/**
 * 机构管理信息Controller
 *
 * @author liujie
 * @date 2022-02-23
 */
@Api(tags = "机构管理信息")
@RestController
@RequestMapping("/web/management")
public class OrganizationManagementController extends BaseController {
  @Autowired
  private IOrganizationManagementService organizationManagementService;

  /**
   * 查询机构管理信息列表
   */
  @ApiOperation("查询机构管理信息列表（分页）")
  @GetMapping("/list")
  public TableDataInfo list(QueryOrganizationManagementDto queryDto) {
    startPage();
    List<OrganizationManagement> list = organizationManagementService.selectOrganizationManagementList(queryDto);
    return getDataTable(list);
  }

  /**
   * 查询机构管理信息列表(不分页)
   */
  @ApiOperation("查询机构管理信息列表（不分页）")
  @GetMapping("/listNoPage")
  public List<OrganizationManagement> listNoPage(QueryOrganizationManagementDto queryDto) {
    List<OrganizationManagement> list = organizationManagementService.selectOrganizationManagementList(queryDto);
    return list;
  }


  /**
   * 获取机构管理信息详细信息
   */
  @ApiOperation("获取机构管理信息详细信息")
  @GetMapping(value = "/{ormId}")
  public AjaxResult getInfo(@PathVariable("ormId") Long ormId) {
    return AjaxResult.success(organizationManagementService.selectOrganizationManagementByOrmId(ormId));
  }

  /**
   * 新增机构管理信息
   */
  @ApiOperation("新增机构管理信息")
  @Log(title = "机构管理信息", businessType = BusinessType.INSERT)
  @PostMapping("/add")
  public AjaxResult addSave(@RequestBody InsertOrganizationManagementDto dto) throws Exception {
    return toAjax(organizationManagementService.insertOrganizationManagement(dto));
  }

  /**
   * 修改机构管理信息
   */
  @ApiOperation("修改机构管理信息")
  @Log(title = "机构管理信息", businessType = BusinessType.UPDATE)
  @PutMapping("/edit")
  public AjaxResult editSave(@RequestBody UpdateOrganizationManagementDto dto) {
    return toAjax(organizationManagementService.updateOrganizationManagement(dto));
  }

  /**
   * 删除机构管理信息
   */
  @ApiOperation("删除机构管理信息")
  @Log(title = "机构管理信息", businessType = BusinessType.DELETE)
  @DeleteMapping("/{ormId}")
  public AjaxResult remove(@PathVariable Long ormId) {
    return toAjax(organizationManagementService.deleteOrganizationManagementByOrmId(ormId));
  }
}